var onCancelWordPic = function(fileId, id) {
	$("#" + fileId).hide();
	fileList.remove(id);
};
$(function(){
	$("#upload").uploadify({
        swf: _contextPath+'/common/uploadify/uploadify.swf',
        uploader : contextPath+'/sys/upload.htm',
        queueID: 'fileQueue',
        auto: true,
        fileObjName :'file',
        buttonText: '选择图片',
        multi : true,
        queueSizeLimit: 10 ,
        removeCompleted : true,
        fileTypeExts: '*.jpg;*.gif;*.jpeg;*.png;*.bmp;',
        onUploadSuccess: function(file, data, response){
	       	var obj = JSON.parse(data); 
	       	$("#"+file.id).find("div.cancel>a").attr("href","javascript:onCancelWordPic('"+file.id+"','"+obj.id+"');");
       		var fileObj  = {}
       		
       		if(obj.fileInDB){//上传并且入库成功
       			var s=$("#all_words").val();
       			$("#images").append('<li id="'+obj.filename.substring(25,30)+'" onclick="deleteImg(\''+obj.filename.substring(25,30)+'\',\''+obj.filename+'\')" style="float:left;list-style-type: none;line-height:180px;*font-size:157px;"><img rel="800:485" width="180" height="109.125" src="http://120.55.241.58/'+obj.filename+'"></li>');
       			$("#all_words").val(s+","+obj.filename);				
        	} else {
        		alert("上传文件失败，请联系管理员");
        	}
	       		
        },
        onError: function(event, queueID, fileObj) {
            sAlert("文件:" + fileObj.name + "上传失败");
        }
    });

	
	
	$("#upload2").uploadify({
        swf: _contextPath+'/common/uploadify/uploadify.swf',
        uploader : contextPath+'/sys/upload.htm',
        queueID: 'fileQueue',
        auto: true,
        fileObjName :'file',
        buttonText: '选择图片',
        multi : true,
        queueSizeLimit: 10 ,
        removeCompleted : true,
        fileTypeExts: '*.jpg;*.gif;*.jpeg;*.png;*.bmp;',
        onUploadSuccess: function(file, data, response){
	       	var obj = JSON.parse(data); 
	       	$("#"+file.id).find("div.cancel>a").attr("href","javascript:onCancelWordPic('"+file.id+"','"+obj.id+"');");
       		var fileObj  = {}
       		
       		if(obj.fileInDB){//上传并且入库成功
       			var s=$("#all_words2").val();
       			$("#images2").append('<li style="line-height:180px;*font-size:157px;"><img rel="800:485" width="180" height="109.125" src="http://120.55.241.58/'+obj.filename+'"></li>');
       			$("#all_words2").val(s+","+obj.filename);				
        	} else {
        		alert("上传文件失败，请联系管理员");
        	}
	       		
        },
        onError: function(event, queueID, fileObj) {
            sAlert("文件:" + fileObj.name + "上传失败");
        }
    });
	
	
	$("#upload3").uploadify({
        swf: _contextPath+'/common/uploadify/uploadify.swf',
        uploader : contextPath+'/sys/upload.htm',
        queueID: 'fileQueue',
        auto: true,
        fileObjName :'file',
        buttonText: '选择图片',
        multi : true,
        queueSizeLimit: 10 ,
        removeCompleted : true,
        fileTypeExts: '*.jpg;*.gif;*.jpeg;*.png;*.bmp;',
        onUploadSuccess: function(file, data, response){
	       	var obj = JSON.parse(data); 
	       	$("#"+file.id).find("div.cancel>a").attr("href","javascript:onCancelWordPic('"+file.id+"','"+obj.id+"');");
       		var fileObj  = {}
       		
       		if(obj.fileInDB){//上传并且入库成功
       			var s=$("#all_words3").val();
       			$("#images3").append('<li style="line-height:180px;*font-size:157px;"><img rel="800:485" width="180" height="109.125" src="http://120.55.241.58/'+obj.filename+'"></li>');
       			$("#all_words3").val(s+","+obj.filename);				
        	} else {
        		alert("上传文件失败，请联系管理员");
        	}
	       		
        },
        onError: function(event, queueID, fileObj) {
            sAlert("文件:" + fileObj.name + "上传失败");
        }
    });
	
	$("#upload4").uploadify({
        swf: _contextPath+'/common/uploadify/uploadify.swf',
        uploader : contextPath+'/sys/upload.htm',
        queueID: 'fileQueue',
        auto: true,
        fileObjName :'file',
        buttonText: '选择文件',
        multi : true,
        queueSizeLimit: 10 ,
        removeCompleted : true,
        fileTypeExts: '*.jpg;*.gif;*.jpeg;*.png;*.bmp;*.zip;*.rar;*.xls;*.xlsx;*.doc;*.docx;*.txt;*.pdf',
        onUploadSuccess: function(file, data, response){
	       	var obj = JSON.parse(data); 
	       	$("#"+file.id).find("div.cancel>a").attr("href","javascript:onCancelWordPic('"+file.id+"','"+obj.id+"');");
       		var fileObj  = {}
       		
       		if(obj.fileInDB){//上传并且入库成功
       			var s=$("#all_words4").val();
       			$("#images4").append('<li style="line-height:180px;*font-size:157px;"><a href="http://120.55.241.58/'+obj.filename+'">文件下载</li>');
       			$("#all_words4").val(s+","+obj.filename);
       			
       			var o=$("#oname").val();
       			$("#oname").val(o+","+obj.oname);
        	} else {
        		alert("上传文件失败，请联系管理员");
        	}
	       		
        },
        onError: function(event, queueID, fileObj) {
            sAlert("文件:" + fileObj.name + "上传失败");
        }
    });
	$("#uploadfw").uploadify({
        swf: _contextPath+'/common/uploadify/uploadify.swf',
        uploader : contextPath+'/sys/upload.htm',
        queueID: 'fileQueue',
        auto: true,
        fileObjName :'file',
        buttonText: '选择图片',
        multi : true,
        queueSizeLimit: 10 ,
        removeCompleted : true,
        fileTypeExts: '*.jpg;*.gif;*.jpeg;*.png;*.bmp;',
        onUploadSuccess: function(file, data, response){
	       	var obj = JSON.parse(data); 
	       	$("#"+file.id).find("div.cancel>a").attr("href","javascript:onCancelWordPic('"+file.id+"','"+obj.id+"');");
       		var fileObj  = {}
       		
       		if(obj.fileInDB){//上传并且入库成功
       			var s=$("#fw").val();
       			$("#imagesfw").append('<li id="'+obj.filename.substring(25,30)+'" onclick="deleteImgfw(\''+obj.filename.substring(25,30)+'\',\''+obj.filename+'\')" style="float:left;list-style-type: none;line-height:180px;*font-size:157px;"><img rel="800:485" width="180" height="109.125" src="http://120.55.241.58/'+obj.filename+'"></li>');
       			$("#fw").val(s+","+obj.filename);				
        	} else {
        		alert("上传文件失败，请联系管理员");
        	}
	       		
        },
        onError: function(event, queueID, fileObj) {
            sAlert("文件:" + fileObj.name + "上传失败");
        }
    });
	
	
	$("#uploadify_hz").uploadify({
		swf : _contextPath + '/common/uploadify/uploadify.swf',
		uploader : contextPath+'/sys/upload.htm',
		queueID : 'fileQueue',
		auto : true,
		fileObjName : 'file',
		buttonText : '选择',
		multi : false,
		queueSizeLimit : 10,
		removeCompleted : true,
		fileTypeExts : '*.csv;*.xls;*.xlsx',
		onUploadSuccess : function(file, data, response) {
			var obj = JSON.parse(data);
			$("#" + file.id).find("div.cancel>a").attr(
					"href",
					"javascript:onCancelWordPic('" + file.id
							+ "','" + obj.id + "');");
			var fileObj = {}

			if (obj.fileInDB) {//上传并且入库成功

				$("#hz_word").val(obj.filename);

			} else {
				alert("上传文件失败，请联系管理员");
			}
		},
		onError : function(event, queueID, fileObj) {
			sAlert("文件:" + fileObj.name + "上传失败");
		}
	});

});

